<extend name="Public:base" />
<block name="title">转诊会诊</block>
<block name="content">
    <form id="ajaxForm">
        <input type="hidden"  name="hospital_now" id="hospital_now">
        <input type="hidden"  name="pid" id="pid">
        <input type="hidden"  name="cateid" id="cateid">
        <div class="weui-panel__bd ">
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">医院</label></div>
                <div class="weui-cell__bd ">
                    <div class="weui-cell__bd weui-input input_border huizhen_zhuanzhen">
                        <input class="weui-input" type="text" placeholder="请选择医院" name="" id="hospital_now_name" disabled="disabled">
                        <a href="__MODULE__/Referral/hospitallist" class="zhuand">转到</a>
                    </div>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">患者</label></div>
                <div class="weui-cell__bd ">
                    <div class="weui-cell__bd weui-input input_border huizhen_zhuanzhen">
                        <input type="hidden" name="pname" class="pname">
                        <input class="weui-input pname" type="text" placeholder="请选择患者" disabled="disabled">
                        <a href="__MODULE__/Referral/patientlist" class="zhuand">转到</a>
                    </div>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">方式</label></div>
                <div class="weui-cell__bd sele_xial">
                    <select class="weui-select input_border  " name="type">
                        <option value="1">转诊</option>
                        <option value="2">会诊</option>
                    </select>
                </div>
            </div>
            <div class="weui-cell beizhu_kuang">
                <div class="weui-cell__hd"><label class="weui-label xinxi_label">备注</label></div>
                <div class="weui-cell__bd ">
                    <textarea class="weui-textarea" placeholder="请输入文本" rows="3" name="remarks"></textarea>
                </div>
            </div>
            <div class="button-sp-area xinxi_but_area">
                <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default"  onclick="history.go(-1)">返回</a>
                <a href="javascript:;" class="weui-btn weui-btn_mini bingli_but" id="add">提交</a>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        $(function(){
            referral = JSON.parse(localStorage.getItem('referral'));
            patient = JSON.parse(localStorage.getItem('patient'));
            cateid = JSON.parse(localStorage.getItem('cateid'));
            if(referral){
                $("#hospital_now").val(referral.hos_now_id);
                $("#hospital_now_name").val(referral.hos_now_name);
            }
            if(patient){
                $("#pid").val(patient.pid);
                $(".pname").val(patient.pname);
            }
            if(cateid){
                $("#cateid").val(cateid);
            }
            $("#add").click(function(){
                var hospital_now_name       = $('#hospital_now_name').val();
                var pname                   = $('#pname').val();
                var newpass2    = $('#newpass2').val();
                if(hospital_now_name == ''){
                    layer.msg('请选择医院！');
                    return false;
                }
                if(pname == ''){
                    layer.msg('请选择患者！');
                    return false;
                }
                var formData = $('#ajaxForm').serialize();
                $.ajax({
                    type:'post',
                    url:'__MODULE__/Referral/index',
                    data:formData,
                    cache:false,
                    dataType:'json',
                    success:function(res){
                        if(res.code == 0){
                            layer.msg(res.msg,{time:2000},function () {
                                localStorage.removeItem('referral');
                                localStorage.removeItem('patient');
                                localStorage.removeItem('cateid');
                                window.location.href = res.url;
                            });
                            return false;
                        }else{
                            layer.msg(res.msg);
                            return false;
                        }
                    }
                });
            });
        });
    </script>
</block>